package cn.spike.rockcc.service.impl;

import cn.spike.rockcc.domain.MediaFile;
import cn.spike.rockcc.service.IMediaFileService;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author:spike
 * @create:2023-03-16 12:35
 */
@Component
@RocketMQMessageListener(
        consumerGroup = "service-consumer-media",
        topic="media-topic",
        selectorExpression="media-tags",
        messageModel= MessageModel.CLUSTERING)
public class ConsumerServiceImpl implements RocketMQListener<String> {

    @Autowired
    private IMediaFileService mediaFileService;

    @Override
    public void onMessage(String jsonStr) {
        MediaFile mediaFile = JSON.parseObject(jsonStr, MediaFile.class);
        mediaFileService.handleFile2m3u8(mediaFile);
    }
}
